﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using QLKhachSan.DTO;
using System.Data.SqlClient;
using QLKhachSan.DAO;
using QLKhachSan.BUS;
using DevExpress.XtraEditors;

namespace QLKhachSan.GUI
{
    public partial class fDanhSachPhong : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public fDanhSachPhong()
        {
            InitializeComponent();
           
        }
        private fDatPhong _fDatPhong = new fDatPhong();
        public static string _TenP;
        private fNhanHuyPhong _fNhanHuyPhong ;
        private fThuePhong _fThuePhong = new fThuePhong();
        private fBangKeDichVu _fBangKeDichVu = new fBangKeDichVu();
        private fDatTiec _fDatTiec = new fDatTiec();
        private fPhieuDenBu _fPhieuDenBu = new fPhieuDenBu();
        private fThanhToan _fThanhToan = new fThanhToan();
        public static int maPhieuDen;
        public static int maKH;        
        public static DateTime ngayDen;
        public static DateTime ngayTra;
        public static Boolean coThue;
        public static Boolean coDat;

        private void loadDanhSachPhong(DataTable data)
        {
            int demConTrong = 0;
            int demDaDat = 0;
            int demDangSD = 0;

            for (int i = 0; i < data.Rows.Count; i++)
            {
                if (data.Rows[i]["TenTrangThai"].ToString().Trim() == "Còn Trống")
                {
                    demConTrong++;
                    ListViewItem it = new ListViewItem(data.Rows[i]["TenPhong"].ToString(), 2);
                    listViewP.Items.Add(it);                 
                   
                }
                if (data.Rows[i]["TenTrangThai"].ToString().Trim() == "Đã Đặt")
                {
                    demDaDat++;
                    ListViewItem it = new ListViewItem(data.Rows[i]["TenPhong"].ToString(), 1);
                    listViewP.Items.Add(it);
                }
                if (data.Rows[i]["TenTrangThai"].ToString().Trim() == "Đã Được Thuê")
                {
                    demDangSD++;
                    ListViewItem it = new ListViewItem(data.Rows[i]["TenPhong"].ToString(), 0);
                    listViewP.Items.Add(it);
                }
            }
            labelConTrong.Text = "Có " + demConTrong + " Phòng ";
            labelDaDat.Text = "Có " + demDaDat + " Phòng ";
            labelDaSD.Text = "Có " + demDangSD + " Phòng ";
        }
        private void fDanhSachPhong_Load(object sender, EventArgs e)
        {
            // Danh Sach Phong
            listViewP.Clear();
            loadDanhSachPhong(BUS_Phong.hienthiDanhSachPhongTheoTenPhong());
           
                //Chi Tiet Phong
               
                textBoxTienIch.Enabled = false;
                textBoxTienIch.ResetText();
                textBoxViTri.Enabled = false;
                textBoxViTri.ResetText();
                textBoxKP.Enabled = false;
                textBoxKP.ResetText();
                textBoxLP.Enabled = false;
                textBoxLP.ResetText();
                textBoxGia.Enabled = false;
                textBoxGia.ResetText();
                // Tim Kiem
                simpleButtonOK.Enabled = false;
                simpleButtonHuyTK.Enabled = false;
                simpleButtonTK.Enabled = true;
                DataTable dt_LoaiPhong = BUS_LoaiPhong.hienthiDanhSachLoaiPhong();
                for (int i = 0; i < (dt_LoaiPhong.Rows.Count); i++)
                {
                    comboBoxLP.Items.Add(dt_LoaiPhong.Rows[i]["TenLP"]);
                }
                comboBoxLP.Text = dt_LoaiPhong.Rows[0]["TenLP"].ToString();

                DataTable dt_KieuPhong = BUS_KieuPhong.hienthiDanhSachKieuPhong();
                for (int i = 0; i < (dt_KieuPhong.Rows.Count); i++)
                {
                    comboBoxKP.Items.Add(dt_KieuPhong.Rows[i]["TenKP"]);
                }
                comboBoxKP.Text = dt_KieuPhong.Rows[0]["TenKP"].ToString();
                textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;              
                textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
                radioButtonGiaTu.Enabled = false;
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                radioButtonKP.Enabled = false;                
                radioButtonLP.Enabled = false;
                radioButtonTienIch.Enabled = false;
                radioButtonViTri.Enabled = false;
                radioButtonNgay.Enabled = false;
                simpleButtonTK.Enabled = true;
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                //button
                simpleButtonThue.Enabled = false;
                simpleButtonDat.Enabled = false;
                simpleButtonDB.Enabled = false;
                simpleButtonDT.Enabled = false;
                simpleButtonTT.Enabled = false;
                simpleButtonDV.Enabled = false;
                simpleButtonHuy.Enabled = false;             
            
        }

        private void listViewP_MouseClick(object sender, MouseEventArgs e)
        {
        
              
        }

        private void listViewP_SelectedIndexChanged(object sender, EventArgs e)
        {
          
            // Chi Tiet Phong + button       

            _TenP = listViewP.FocusedItem.Text; ;        
            DataTable dt_p = BUS_Phong.hienthiDanhSachPhongTheoTenPhong();
            coThue = false;
            coDat = false;
            for (int i = 0; i < (dt_p.Rows.Count); i++)
            {
                if (listViewP.FocusedItem.Text.Trim() == dt_p.Rows[i]["TenPhong"].ToString())
                {
                    textBoxTienIch.Text = dt_p.Rows[i]["TienIch"].ToString();                   
                    textBoxLP.Text = dt_p.Rows[i]["TenLP"].ToString();
                    textBoxKP.Text = dt_p.Rows[i]["TenKP"].ToString();
                    textBoxGia.Text = dt_p.Rows[i]["Gia"].ToString();
                    textBoxViTri.Text = dt_p.Rows[i]["ViTri"].ToString();
                    if (dt_p.Rows[i]["TenTrangThai"].ToString().Trim() == "Còn Trống")
                    {
                        if (fLogin.quyen == "admin")
                        {
                            simpleButtonThue.Enabled = false;
                            simpleButtonDat.Enabled = false;
                            simpleButtonDB.Enabled = false;
                            simpleButtonDT.Enabled = false;
                            simpleButtonTT.Enabled = false;
                            simpleButtonDV.Enabled = false;
                            simpleButtonHuy.Enabled = false;
                        }
                        else if (fLogin.quyen == "user")
                        {
                            simpleButtonThue.Enabled = true;
                            simpleButtonDat.Enabled = true;
                            simpleButtonDB.Enabled = false;
                            simpleButtonDT.Enabled = false;
                            simpleButtonTT.Enabled = false;
                            simpleButtonDV.Enabled = false;
                            simpleButtonHuy.Enabled = false;
                        }
                        labelMa.Text = "Tên Phòng: " + listViewP.FocusedItem.Text;
                        
                        
                    }
                    else if (dt_p.Rows[i]["TenTrangThai"].ToString().Trim() == "Đã Đặt")
                    {
                        if (fLogin.quyen == "admin")
                        {
                            simpleButtonThue.Enabled = false;
                            simpleButtonDat.Enabled = false;
                            simpleButtonDB.Enabled = false;
                            simpleButtonDT.Enabled = false;
                            simpleButtonTT.Enabled = false;
                            simpleButtonDV.Enabled = false;
                            simpleButtonHuy.Enabled = false;
                        }
                        else if (fLogin.quyen == "user")
                        {
                            simpleButtonDat.Enabled = false;
                            simpleButtonDB.Enabled = false;
                            simpleButtonDT.Enabled = false;
                            simpleButtonTT.Enabled = false;
                            simpleButtonDV.Enabled = false;
                            simpleButtonHuy.Enabled = true;
                        }
                        DataTable dta_ma = DAO_PhieuDatPhong.LayMaDatPhongTheoTenPhong(listViewP.FocusedItem.Text.Trim());
                        for (int j = 0; j < dta_ma.Rows.Count;j++ )
                        {
                            if (DateTime.Parse(dta_ma.Rows[j]["NgayDen"].ToString()) >= DateTime.Now)
                            {

                                if (DateTime.Parse(dta_ma.Rows[j]["NgayDen"].ToString()).Date >= DateTime.Now.Date)
                                {
                                    if (DateTime.Now.Hour <= 12)
                                    {
                                    simpleButtonThue.Enabled = true;
                                    ngayDen = DateTime.Parse(dta_ma.Rows[j]["NgayDen"].ToString());
                                    coThue = true;
                                    }
                                }
                                else
                                {
                                    simpleButtonThue.Enabled = false;
                                    coThue = false;
                                }
                              
                                labelMa.Text = "Mã Đặt Phòng :          " + dta_ma.Rows[j]["MaPhieuDat"].ToString() + "\n Ngày nhận : " + dta_ma.Rows[j]["NgayDen"].ToString();
                                break;
                            }
                        }
                                        
  
                    }
                    else if (dt_p.Rows[i]["TenTrangThai"].ToString().Trim() == "Đã Được Thuê")
                    {
                          if (fLogin.quyen == "admin")
                        {
                            simpleButtonThue.Enabled = false;
                            simpleButtonDat.Enabled = false;
                            simpleButtonDB.Enabled = false;
                            simpleButtonDT.Enabled = false;
                            simpleButtonTT.Enabled = false;
                            simpleButtonDV.Enabled = false;
                            simpleButtonHuy.Enabled = false;
                        }
                          else if (fLogin.quyen == "user")
                          {
                              simpleButtonThue.Enabled = false;
                              simpleButtonDat.Enabled = true;
                              simpleButtonDB.Enabled = true;
                              simpleButtonDT.Enabled = true;
                              simpleButtonTT.Enabled = true;
                              simpleButtonDV.Enabled = true;
                              simpleButtonHuy.Enabled = false;
                          }

                          DataTable dta_ctpd = BUS_CTPhieuDen.HienThiDanhSachCTPhieuDenTheoTenPhong(listViewP.FocusedItem.Text);
                        for (int j = 0; j < dta_ctpd.Rows.Count; j++)
                        {
                            if (DateTime.Parse(dta_ctpd.Rows[j]["NgayTra"].ToString()) >= DateTime.Now)
                            {
                                coDat = true;
                                ngayTra = DateTime.Parse(dta_ctpd.Rows[j]["NgayTra"].ToString());
                                DTO_PhieuDen dto_pd = new DTO_PhieuDen();
                                dto_pd.MaPhieuDen = int.Parse(dta_ctpd.Rows[dta_ctpd.Rows.Count - 1]["MaPhieuDen"].ToString());
                                maPhieuDen = int.Parse(dta_ctpd.Rows[dta_ctpd.Rows.Count - 1]["MaPhieuDen"].ToString());
                                DataTable dta_pd = BUS_PhieuDen.hienthiDanhSachPhieuDenTheoMaPhieuDen(dto_pd);
                                maKH = int.Parse(dta_pd.Rows[0]["MaKH"].ToString());
                                labelMa.Text = "Mã Phiếu đến :              " + dta_ctpd.Rows[dta_ctpd.Rows.Count - 1]["MaPhieuDen"].ToString() + "\n Ngày Trả: " + dta_ctpd.Rows[j]["NgayTra"].ToString();                               
                                break;
                            }
                        }      
                       
                    }
                    break;
                }
            }           
          
        }

        private void simpleButtonDat_Click(object sender, EventArgs e)
        {           
            if (_fDatPhong == null || _fDatPhong.IsDisposed) // Chua Tao or Chua Mo fDatPhong, Tạo Mới fDatPhong
            {
                this.Close();                              
                _fDatPhong.MdiParent = fMain.ActiveForm;
                _fDatPhong.Show();
            }
            else
            {
                this.Close();                         
                _fDatPhong.MdiParent = fMain.ActiveForm;
                _fDatPhong.Show();
            } 
        }

        private void simpleButtonHuy_Click(object sender, EventArgs e)
        {
            if (_fNhanHuyPhong == null || _fNhanHuyPhong.IsDisposed) // Chua Tao or Chua Mo fNhanHuyPhong, Tạo Mới fNhanHuyPhong
            {
                this.Close();
                _fNhanHuyPhong = new fNhanHuyPhong();
                _fNhanHuyPhong.ShowDialog();
            }
            else
            {
                this.Close();
                _fNhanHuyPhong.Close();
                _fNhanHuyPhong = new fNhanHuyPhong();
                _fNhanHuyPhong.ShowDialog();
            }
        }

        private void simpleButtonThue_Click(object sender, EventArgs e)
        {
            if (_fThuePhong == null || _fThuePhong.IsDisposed) // Chua Tao or Chua Mo fThuePhong, Tạo Mới fThuePhong
            {
                this.Close();
                _fThuePhong.MdiParent = fMain.ActiveForm;
                _fThuePhong.Show();
            }
            else
            {
                this.Close();
                _fThuePhong.MdiParent = fMain.ActiveForm;
                _fThuePhong.Show();
            } 
        }

        private void simpleButtonDV_Click(object sender, EventArgs e)
        {
            if (_fBangKeDichVu == null || _fBangKeDichVu.IsDisposed) // Chua Tao or Chua Mo fBangKeDichVu, Tạo Mới fBangKeDichVu
            {
                this.Close();
                _fBangKeDichVu = new fBangKeDichVu();
                _fBangKeDichVu.MdiParent = fMain.ActiveForm;
                _fBangKeDichVu.Show();
            }
            else
            {
                this.Close();
                _fBangKeDichVu.Close();
                _fBangKeDichVu = new fBangKeDichVu();
                _fBangKeDichVu.MdiParent = fMain.ActiveForm;
                _fBangKeDichVu.Show();
            } 
        }

        private void simpleButtonDT_Click(object sender, EventArgs e)
        {
            if (_fDatTiec == null || _fDatTiec.IsDisposed) // Chua Tao or Chua Mo fDatTiec, Tạo Mới fDatTiec
            {
                  this.Close();
                _fDatTiec = new fDatTiec();
                _fDatTiec.MdiParent = fMain.ActiveForm;
                _fDatTiec.Show();
            }
            else
            {
                this.Close();
                _fDatTiec.Close();
                _fDatTiec = new fDatTiec();
                _fDatTiec.MdiParent = fMain.ActiveForm;
                _fDatTiec.Show();
            } 
        }

        private void simpleButtonDB_Click(object sender, EventArgs e)
        {
            if (_fPhieuDenBu == null || _fPhieuDenBu.IsDisposed) // Chua Tao or Chua Mo fPhieuDenBu, Tạo Mới fPhieuDenBu
            {
                this.Close();
                _fPhieuDenBu = new fPhieuDenBu();
                _fPhieuDenBu.MdiParent = fMain.ActiveForm;
                _fPhieuDenBu.Show();
            }
            else
            {
                this.Close();
                _fPhieuDenBu.Close();
                _fPhieuDenBu = new fPhieuDenBu();
                _fPhieuDenBu.MdiParent = fMain.ActiveForm;
                _fPhieuDenBu.Show();
            } 
        }

        private void simpleButtonTT_Click(object sender, EventArgs e)
        {
            if (_fThanhToan == null || _fThanhToan.IsDisposed) // Chua Tao or Chua Mo fThanhToan, Tạo Mới fThanhToan
            {
                this.Close();
                _fThanhToan = new fThanhToan();
                _fThanhToan.MdiParent = fMain.ActiveForm;
                _fThanhToan.Show();
            }
            else
            {
                this.Close();
                _fThanhToan.Close();
                _fThanhToan = new fThanhToan();
                _fThanhToan.MdiParent = fMain.ActiveForm;
                _fThanhToan.Show();
            } 
        }

        private void dateTimePickerTu_ValueChanged(object sender, EventArgs e)
        {
            dateTimePickerDen.MinDate = dateTimePickerTu.Value;
        }

        private void simpleButtonTK_Click(object sender, EventArgs e)
        {
            simpleButtonOK.Enabled = true;
            simpleButtonHuyTK.Enabled = true;
            simpleButtonTK.Enabled = false;         
            textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
            textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
            radioButtonGiaTu.Enabled = true;
            textBoxGiaTu.Enabled = false;
            textBoxGiaTu.ResetText();
            textBoxGiaDen.Enabled = false;
            textBoxGiaDen.ResetText();
            radioButtonKP.Enabled = true;
            radioButtonLP.Enabled = true;
            radioButtonTienIch.Enabled = true;
            radioButtonViTri.Enabled = true;
            radioButtonNgay.Enabled = true;        
            comboBoxKP.Enabled = false;
            comboBoxLP.Enabled = false;
            dateTimePickerDen.Enabled = false;
            dateTimePickerTu.Enabled = false;
            radioButtonNgay.Checked = true;
            dateTimePickerDen.MinDate = dateTimePickerTu.Value;
        }

        private void textBoxTimKiem_MouseClick(object sender, MouseEventArgs e)
        {
            if (textBoxTimKiem.Text.Trim() == "Nhập Từ Khóa Tìm Kiếm...")
            {
                textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowText;
                textBoxTimKiem.ResetText();
            }
        }

        private void simpleButtonHuyTK_Click(object sender, EventArgs e)
        {
            simpleButtonOK.Enabled = false;
            simpleButtonHuyTK.Enabled = false;
            simpleButtonTK.Enabled = true;            
            textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
            textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
            textBoxTimKiem.Enabled = false;
            radioButtonGiaTu.Enabled = false;
            textBoxGiaTu.Enabled = false;
            textBoxGiaTu.ResetText();
            textBoxGiaDen.Enabled = false;
            textBoxGiaDen.ResetText();
            listViewP.Clear();
            loadDanhSachPhong(BUS_Phong.hienthiDanhSachPhongTheoTenPhong());
            radioButtonKP.Enabled = false;
            radioButtonLP.Enabled = false;
            radioButtonTienIch.Enabled = false;
            radioButtonViTri.Enabled = false;
            radioButtonNgay.Enabled = false;
            simpleButtonTK.Enabled = true;
            comboBoxKP.Enabled = false;
            comboBoxLP.Enabled = false;
            dateTimePickerDen.Enabled = false;
            dateTimePickerTu.Enabled = false;
        }

        private void radioButtonTienIch_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonTienIch.Checked == true || radioButtonViTri.Checked == true)
            {

                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                textBoxGiaTu.Enabled = false;
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                textBoxTimKiem.Enabled = true;
            }
           
        }

        private void radioButtonViTri_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonTienIch.Checked == true || radioButtonViTri.Checked == true)
            {

                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                textBoxTimKiem.Enabled = true;
            }
        }

        private void radioButtonLP_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonLP.Checked == true )
            {

                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = true;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                textBoxTimKiem.Enabled = false;
                textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
                textBoxTimKiem.Enabled = false;
            }            
        }

        private void radioButtonKP_CheckedChanged(object sender, EventArgs e)
        {
             if (radioButtonKP.Checked == true )
            {

                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                comboBoxKP.Enabled = true;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                textBoxTimKiem.Enabled = false;
                textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
                textBoxTimKiem.Enabled = false;
            }            
        }

        private void radioButtonGiaTu_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonGiaTu.Checked == true)
            {
               
                textBoxGiaDen.Enabled = true;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = true;
                textBoxGiaTu.ResetText();
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = false;
                dateTimePickerTu.Enabled = false;
                textBoxTimKiem.Enabled = false; textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
                textBoxTimKiem.Enabled = false;
            }         
        }

        private void radioButtonNgay_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButtonNgay.Checked == true)
            {
                textBoxGiaDen.Enabled = false;
                textBoxGiaDen.ResetText();
                textBoxGiaTu.Enabled = false;
                textBoxGiaTu.ResetText();
                comboBoxKP.Enabled = false;
                comboBoxLP.Enabled = false;
                dateTimePickerDen.Enabled = true;
                dateTimePickerTu.Enabled = true;
                textBoxTimKiem.Enabled = false;
                textBoxTimKiem.Font = new System.Drawing.Font("Times New Roman", 9.75F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                textBoxTimKiem.ForeColor = System.Drawing.SystemColors.WindowFrame;
                textBoxTimKiem.Text = "Nhập Từ Khóa Tìm Kiếm...";
                textBoxTimKiem.Enabled = false;
            }         
        }

        private void simpleButtonOK_Click(object sender, EventArgs e)
        {
            if(radioButtonTienIch.Checked == true)
            {
                listViewP.Clear();
                loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoTienTich(textBoxTimKiem.Text.Trim()));
            }
            if(radioButtonViTri.Checked == true )
            {
                listViewP.Clear();
                loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoViTri(textBoxTimKiem.Text.Trim()));
            }
            if(radioButtonLP.Checked == true)
            {
                listViewP.Clear();
                loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoTenLoaiPhong(comboBoxLP.Text.Trim()));
            }
            if(radioButtonKP.Checked == true)
            {
                listViewP.Clear();
                loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoTenKieuPhong(comboBoxKP.Text.Trim()));
            }
            if(radioButtonGiaTu.Checked == true)
            {
                if (int.Parse(textBoxGiaTu.Text) <= int.Parse(textBoxGiaDen.Text))
                {
                    listViewP.Clear();
                    loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoKhoangGia(int.Parse(textBoxGiaTu.Text),int.Parse(textBoxGiaDen.Text)));
                }
                else
                {
                    MessageBox.Show("Giá Trị Từ - Đến Không Hợp Lệ!!!???", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (radioButtonNgay.Checked == true)
            {
                listViewP.Clear();
                loadDanhSachPhong(DAO_Phong.TimKiemDSPhongTheoKhoangNgayThue(dateTimePickerTu.Value, dateTimePickerDen.Value));
            }
        }

        private void labelMa_Click(object sender, EventArgs e)
        {

        }

     
        


      
    }
}